import type { MockMethod } from 'vite-plugin-mock'

import { resultPageSuccess, resultSuccess } from './_util'

const userInfo = {
  id: '@id',
  name: 'Ervin Howell',
  username: 'Antonette',
  email: '@email',
  address: '@county(true)',
  phone: '010-692-6593 x09125',
  website: '@domain',
  lastIp: '@ip',
  description: '@paragraph'
}

const userList = Array.from({ length: 297 }, () => ({
  id: '@id',
  account: '@name',
  email: '@email',
  domain_total: 20,
  dns_addr: '@domain',
  group: '普通分组',
  state: 1,
  remark: '测试备注',
  created_at: '@datetime',
  updated_at: '@datetime'
}))

export default [
  {
    method: 'get',
    url: '/mock/user/info',
    statusCode: 200,
    response: () => resultSuccess(userInfo)
  },
  {
    method: 'get',
    url: '/mock/user/list',
    statusCode: 200,
    response: () => {
      return resultPageSuccess(0, 20, userList)
    }
  }
] as MockMethod[]
